<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LoginSSH</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet"  href="/css/bootstrapValidator.min.css"/>
    <link rel="stylesheet" href="/css/login.css">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
    <h3>在线SSH连接工具</h3>
</nav>
<div class="container-fluid" >
    <div class="login-form  col-lg-4 col-lg-offset-4  col-sm-6 col-sm-offset-3 col-xs-8 col-xs-offset-2 ">
        <form action="/websshpage" method="post">
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">主机 :</span>
                    <input type="text" class="form-control" name="host">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">端口 :</span>
                    <input type="text" class="form-control" name="port">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">账号 :</span>
                    <input type="text" class="form-control" name="username">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">密码 :</span>
                    <input type="password" class="form-control" name="password">
                </div>
            </div>
            <div class="form-group">
                <div class="checkbox">
                    <label>
                        &nbsp;<input type="checkbox" name="remember"> 记住信息
                    </label>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">连接</button>
            &nbsp;
            <button type="reset" class="btn btn-default">重置</button>
        </form>
   </div>
</div>
</body>
<script src="/js/jquery-3.4.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrapValidator.min.js"></script>
<script>
    $(function () {
        if(localStorage.getItem("check")){
            let obj = JSON.parse(localStorage.getItem("check"))
            $("input[name='remember']").attr("checked",obj.check);
            $("input[name='host']").val(obj.host);
            $("input[name='port']").val(obj.port);
            $("input[name='username']").val(obj.username);
            $("input[name='password']").val(obj.password);
        }
        $('form').bootstrapValidator({
            fields: {
                host: {
                    validators: {
                        notEmpty: {
                            message: '主机地址不能为空'
                        }
                    }
                },
                port: {
                    validators: {
                        notEmpty: {
                            message: '端口号不能为空'
                        }
                    }
                },
                username: {
                    validators: {
                        notEmpty: {
                            message: '登录账号不能为空'
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: '登录密码不能为空'
                        }
                    }
                }
            }
        });
    });
</script>
</html>
